package com.EM1.www.servlet;

import com.EM1.www.dao.ConnectQuestion;
import com.EM1.www.util.UpdateSession;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet("/DeleteQuestion")
public class DeleteQuestion extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        String id = request.getParameter("id");
        int deleteid=Integer.parseInt(id);
        ConnectQuestion connectQuestion=new ConnectQuestion();
        try {
            connectQuestion.deleteQuestion(deleteid);
            UpdateSession.updateQuestion(request);
            request.getRequestDispatcher("questionbank.jsp").forward(request,response);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

    }
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
